package com.lrs.java.j2se_self.gui;
import java.awt.*;
import java.awt.event.*;

public class TextMath {
	public static void main(String[] agrs){
		new TMFrame().launchFrame();
	}
}

class TMFrame extends Frame {
	public TextField num1 ,num2 ,num3 ;
	public void launchFrame (){
		num1 = new TextField("num1",10);
		num2 = new TextField("num2",10);
		num3 = new TextField("sum",15);
		Label l1 = new Label("+");
		Button b1 = new Button("=");
		b1.addActionListener(new MyMonitor());
		setLayout(new FlowLayout());
		add(num1);add(l1);add(num2);add(b1);add(num3);
		pack();
		setVisible(true);
	}
	/*
	public static void printMg(){
		System.out.println("success!");
		
	}
	public void printMg1(){
		printMg();
	}
	*/
	private class MyMonitor implements ActionListener {
		public void actionPerformed(ActionEvent e){
			int num  = Integer.parseInt(num1.getText()) + Integer.parseInt(num2.getText());
			num3.setText(""+num);
			/*
			TMFrame tmf = (TMFrame)e.getSource();
			*/
		}
	}
}
/*
class MyMonitor implements ActionListener {
	TMFrame tmf = null;
	
	MyMonitor(TMFrame f){
		this.tmf = f ;
	}
	
	public void actionPerformed(ActionEvent e){
		//System.out.println("OK");
		int num  = Integer.parseInt(tmf.num1.getText()) + Integer.parseInt(tmf.num2.getText());
		tmf.num3.setText(""+num);
		
	}
}
*/